/*
 * DialogIngeschrevenWebinar.java
 *
 * Created on 25-nov-2011, 15:27:58
 */
package gui;

import domein.Gebruiker;
import domein.Webinar;
import domein.WebinarController;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;

/**
 *
 * @author Karolien Sabbe
 */
public class DialogInschrijvenWebinar extends javax.swing.JDialog {

    String onderwerp = "";
    String commentaar = "";
    String instructeur = "";
    ImageIcon foto;
    String datum = "";
    String beginU = "";
    String eindU = "";
    WebinarController wc;
    Webinar web;
    int gid;
    DefaultListModel listDeelnemers;

    public DialogInschrijvenWebinar(java.awt.Frame parent, boolean modal, Webinar web, int gid) {
        super(parent, modal);
        wc = WebinarController.getInstance();


        this.web = web;
        this.gid = gid;
        listDeelnemers = new DefaultListModel();
        for (Gebruiker g : web.getInschrijvingen().values()) {
            listDeelnemers.addElement(g.getFamilienaam() + " " + g.getVoornaam());
        }

        int instructeurID = web.getInstructeur();
        instructeur = ((Gebruiker) wc.getR().getGebruikers().get(instructeurID)).getVoornaam() + " "
                + ((Gebruiker) wc.getR().getGebruikers().get(instructeurID)).getFamilienaam();
        onderwerp = web.getOnderwerp();
        commentaar = web.getCommentaar();
        foto = web.getIcon();
        datum = web.getDag().toString();
        beginU = web.getStartU().toString();
        eindU = web.getEindU().toString();

        initComponents();
        //positie panel:
        Toolkit tk = Toolkit.getDefaultToolkit();

        Dimension screenSize = tk.getScreenSize();
        int screenWidth = screenSize.width;

        setLocation((screenWidth - 824) / 2, 100);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        onderwerpTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        datumTextField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        beginTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        eindTextField = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        instructeurTextField = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        jListDeelnemers = new javax.swing.JList();
        inschrijfButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        commentaarTextArea = new javax.swing.JTextArea();
        lblFoto = new javax.swing.JLabel();
        inschrijfButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setText("Onderwerp");

        onderwerpTextField.setEnabled(false);
        onderwerpTextField.setText(onderwerp);

        jLabel2.setText("Commentaar");

        jLabel3.setText("Datum");

        datumTextField.setEnabled(false);
        datumTextField.setText(datum);

        jLabel4.setText("Begintijd");

        beginTextField.setEnabled(false);
        beginTextField.setText(beginU);

        jLabel5.setText("Eindtijd");

        eindTextField.setEnabled(false);
        eindTextField.setText(eindU);

        jLabel6.setText("Instructeur");

        instructeurTextField.setEnabled(false);
        instructeurTextField.setText(instructeur);

        jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Ingeschreven deelnemers", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));
        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        jListDeelnemers.setModel(listDeelnemers);
        jListDeelnemers.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane2.setViewportView(jListDeelnemers);

        inschrijfButton.setText("Inschrijven");
        inschrijfButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inschrijfButtonActionPerformed(evt);
            }
        });

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        commentaarTextArea.setColumns(20);
        commentaarTextArea.setLineWrap(true);
        commentaarTextArea.setRows(5);
        commentaarTextArea.setWrapStyleWord(true);
        commentaarTextArea.setEnabled(false);
        commentaarTextArea.setText(commentaar);
        jScrollPane1.setViewportView(commentaarTextArea);

        lblFoto.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblFoto.setIcon(foto);
        lblFoto.setBorder(javax.swing.BorderFactory.createEtchedBorder(null, new java.awt.Color(0, 0, 0)));

        inschrijfButton1.setText("Annuleren");
        inschrijfButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                inschrijfButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jLabel6))
                        .addGap(24, 24, 24)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jScrollPane1)
                            .addComponent(instructeurTextField)
                            .addComponent(onderwerpTextField)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(123, 123, 123)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel5)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lblFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel4)))
                        .addGap(19, 19, 19)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(eindTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                            .addComponent(datumTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                            .addComponent(beginTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))))
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(inschrijfButton1, 0, 0, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(inschrijfButton, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(inschrijfButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(inschrijfButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel3)
                                    .addComponent(datumTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(beginTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel5)
                                    .addComponent(eindTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(lblFoto, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(instructeurTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(onderwerpTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(27, 27, 27))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void inschrijfButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inschrijfButtonActionPerformed
    wc.voegWebinarVolgerToe(web.getWebinarID(), gid);
    dispose();
}//GEN-LAST:event_inschrijfButtonActionPerformed

private void inschrijfButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inschrijfButton1ActionPerformed
    dispose();
}//GEN-LAST:event_inschrijfButton1ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField beginTextField;
    private javax.swing.JTextArea commentaarTextArea;
    private javax.swing.JTextField datumTextField;
    private javax.swing.JTextField eindTextField;
    private javax.swing.JButton inschrijfButton;
    private javax.swing.JButton inschrijfButton1;
    private javax.swing.JTextField instructeurTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JList jListDeelnemers;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblFoto;
    private javax.swing.JTextField onderwerpTextField;
    // End of variables declaration//GEN-END:variables
}
